/**
 * Copyright (c) 2024 Hunan OpenValley Digital Industry Development Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef OHOS_EGLRENDERCONTEXT_H
#define OHOS_EGLRENDERCONTEXT_H
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES3/gl3.h>
#include <GLES2/gl2ext.h>
class EglRenderContext {
public:
    EglRenderContext();
    ~EglRenderContext() noexcept;
    EglRenderContext(const EglRenderContext &) = delete;
    void operator==(const EglRenderContext &) = delete;
    EglRenderContext(const EglRenderContext &&) = delete;
    void operator==(const EglRenderContext &&) = delete;
    bool initContext(void *window, int32_t width, int32_t height);
    bool isEglContextReady() const;
    EGLDisplay getEGLDisplay() const;
    EGLContext getEGLContext() const;
    EGLSurface createEglSurface(const EGLint *attribList = nullptr);
    void destroyEglSurface(EGLSurface surface);
    void makeCurrent(EGLSurface surface) const;
    void swapBuffers(EGLSurface surface) const;

protected:
    EGLNativeWindowType eglWindow_;
    EGLDisplay eglDisplay_ = EGL_NO_DISPLAY;
    EGLContext eglContext_ = EGL_NO_CONTEXT;
    EGLConfig eglConfig_ = nullptr;
};
#endif // OHOS_EGLRENDERCONTEXT_H
